<? $this->view('head') ?>
<title>结算报表 - 预订客人对账明细</title>
<link rel="stylesheet" href="<?= $this->www('css/module/master.css') ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?= $this->www('css/module/master/report.css') ?>" type="text/css" />
<script type="text/javascript" src="<?= $this->www('script/module/master.stat.js') ?>"></script>
<script type="text/javascript" src="<?= $this->www('script/plugin/jquery.tablesorter.js') ?>"></script>

<? $this->view('body') ?>
<? $this->view('master/header', array('tab' => 'bbtj')) ?>
<div class="ftt-container">
    <div class="ftt-title clearfix">
        <h2 class="column-left">结算报表 - 预订客人对账明细 [ <?= date('Y-m-d', $this->tmln[0]) ?> 至 <?= date('Y-m-d', $this->tmln[1]) ?> ]</h2>
        <input id="print-button" class="column-right button white" type="button" value="打印报表" onclick="window.print();" />
        <input id="force-button" class="column-right button white" type="button" value="导出报表" title="将当前报表导出为CSV格式下载" onclick="location.href=location.pathname+'.csv'+location.search;" />
    </div>
    <div class="reports-query">
        <form id="form-reports-realtime" action="/master/stat/jsbb-ydkrdzmx" method="get">
            <label for="reports-guest">预订客人</label>
            <input type="text" id="reports-guest" name="bknm" class="ftt-input-text short-text" value="<?= $this->escape($this->bknm) ?>" />
            <label for="reports-date">起始日期</label>
            <input type="text" name="date[0]" id="reports-bdate" class="ftt-input-text short-text input-datepicker" value="<?= date('Y-m-d', $this->tmln[0]) ?>" />
            <label for="reports-date">结束日期</label>
            <input type="text" name="date[1]" id="reports-edate" class="ftt-input-text short-text input-datepicker" value="<?= date('Y-m-d', $this->tmln[1]) ?>" />
            <input type="submit" class="button white" value="查询" />
        </form>
    </div>
    <div class="reports-wrapper">
        <p class="utime">
            当前列表数据更新时间：<span class="update-T"><?= date('Y-m-d H:i:s', $this->time) ?></span>
        </p>
        <table class="report">
            <thead>
                <tr>
                    <th colspan="10">预订客人：<?= $this->escape($this->bknm) ?></th>
                </tr>
                <tr>
                    <th>账单编号</th>
                    <th>订单编号</th>
                    <th>房间名</th>
                    <th>入住客人</th>
                    <th>入住日期</th>
                    <th>离店日期</th>
                    <th>间夜数</th>
                    <th>成交房费(元)</th>
                    <th>账单房费(元)</th>
                    <th>佣金(房费差价)</th>
                </tr>
            </thead>
            <tbody>
                <? $btime = 0 ?>
                <? $etime = 0 ?>
                <? $night = 0 ?>
                <? $night_sum = 0 ?>
                <? $price = 0 ?>
                <? $price_sum = 0 ?>
                <? $brice = 0 ?>
                <? $brice_sum = 0 ?>
                <? $bmnsp = 0 ?>
                <? $bmnsp_sum = 0 ?>
                <? if(empty($this->ydkr)): ?>
                <tr>
                    <td colspan="10" class="none">无记录</td>
                </tr>
                <? else: ?>
                <? foreach ($this->ydkr as $data): ?>
                <tr>
                    <td><a target="_blank" title="订单详情" href="/master/order/detail?oid=<?= $data['o_id'] ?>"><?= $data['o_id'] ?></a></td>
                    <td><a target="_blank" title="账单详情" href="/master/bill/detail?bid=<?= $data['o_bid'] ?>"><?= $data['o_bid'] ?></a></td>
                    <td><a target="_blank" title="房间详情" href="/master/room/detail?rid=<?= $data['o_rid'] ?>"><?= $this->escape($data['o_room']) ?></a></td>
                    <td><?= $this->escape($data['o_glver_name']) ?></td>
                    <td><? $btime = strtotime(date('Y-m-d', $data['o_btime'])) ?><?= date('Y-m-d', $btime) ?></td>
                    <td><? $etime = strtotime(date('Y-m-d', $data['o_etime'])) ?><?= date('Y-m-d', $etime) ?></td>
                    <td><?= $night = ($etime - $btime)/86400 ?><? $night_sum += $night ?></td>
                    <td><?= $data['o_price']/100 ?><? $price_sum += $data['o_price']/100 ?></td>
                    <td><?= $data['o_brice']/100 ?><? $brice_sum += $data['o_brice']/100 ?></td>
                    <td><?= $bmnsp = ($data['o_brice'] - $data['o_price'])/100 ?><? $bmnsp_sum += $bmnsp ?></td>
                </tr>
                <? endforeach; ?>
                <? endif; ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="6" style="text-align:right;">共有&nbsp;<?= count($this->ydkr) ?>&nbsp;条记录，合计：</td>
                    <td><?= $night_sum ?></td>
                    <td><?= $price_sum ?></td>
                    <td><?= $brice_sum ?></td>
                    <td><?= $bmnsp_sum ?></td>
                </tr>
            </tfoot>
        </table>
        <p class="note">
            此报表为实时报表
        </p>
        <p class="copyright">——由房态通提供的报表</p>
    </div>
</div>

<? $this->view('master/footer') ?>
<script type="text/javascript">$(Z.Module.master.stat.jsbbYdkrdzmx.init)</script>
<? $this->view('foot') ?>
